package pers.mihao.quickstream.publish.strategy.scorer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pers.mihao.quickstream.common.util.CollectionUtil;
import pers.mihao.quickstream.publish.strategy.context.ChooseContext;
import pers.mihao.quickstream.publish.strategy.dto.ChooseAccount;

import java.util.List;

/**
 * @author mihao
 * @since 2024/11/25
 */
@Component("accountScorer")
public class AccountScorerFace implements AccountScorer {

    @Autowired(required = false)
    List<AccountScorer> accountScorerList;

    @Override
    public Long scoring(ChooseAccount chooseAccount, ChooseContext chooseContext) {
        Long score = 0L;
        if (CollectionUtil.isEmpty(accountScorerList)) {
            return score;
        }
        for (AccountScorer accountScorer : accountScorerList) {
            if (accountScorer.isMatch(chooseContext)) {
                score += accountScorer.scoring(chooseAccount, chooseContext);
            }
        }
        return score;
    }

    @Override
    public boolean isMatch(ChooseContext chooseContext) {
        return false;
    }
}
